
"""
This file contains all the error codes used in the util subdirectory 

from util.errcode import *

"""
# NOTE: NEED to PREVENT DUPLICATE assignment of the same code value to 
# different VARIABLES
# Error codes have been kept as same as Java impl.

INSUFFICENT_DATA                = 2028
NO_DATABASE_CONNECTION          = 2100
QUERY_FAILED                    = 2101
ACCOUNT_INACTIVE                = 2007
PWD_MISMATCH                    = 1001
SESSION_INVALID                 = 2009
SESSION_PRINCIPAL_MISMATCH      = 2035
IBROKER_INVALID                 = 2004
IBROKER_PRINCIPAL_MISMATCH      = 2010
INAME_NOT_RESOLVED              = 2034
INAME_INVALID                   = 2040

#Legacy constants
UTIL_DB_SQL_STRING                 = 11000
UTIL_DB_INVALID_CONNECTION         = 11001
UTIL_DB_INVALID_CONNECT_PARAMETER  = 11002
UTIL_DB_PUTCONNECTION_SUCCESS      = 11003
UTIL_DB_GETCONNECTION_SUCCESS      = 11004
UTIL_DB_CONNECTION_NOT_AVAILABLE   = 11005
UTIL_DB_CONNECTION_POOL_EXCEPTION  = 11006
UTIL_DB_TRANSACTION_FAILURE        = 11007
UTIL_DB_TRANSACTION_COMMITTED      = 11008
UTIL_DB_TRANSACTION_ROLLED_BACK    = 11009
UTIL_DB_CONNECTED_TO_DB            = 11010

# all error strings must be UNICODE string
dUtilErrorCodeMap = {

INSUFFICENT_DATA: 
    u"Insufficient Data.",
NO_DATABASE_CONNECTION: 
    u"No database connection",
QUERY_FAILED:
    u"SQL query could not be executed",
ACCOUNT_INACTIVE:
    u"Account is inactive",
PWD_MISMATCH:
    u"Password does not match",
SESSION_INVALID:
    u"Session is invalid",    
SESSION_PRINCIPAL_MISMATCH:
    u"Session does not belong to principal",
IBROKER_INVALID:
    u"Ibroker is not valid",
INAME_NOT_RESOLVED:
    u"Iname/Inumber can't be resolved",
INAME_INVALID:
    u"Iname is not valid",
UTIL_DB_PUTCONNECTION_SUCCESS:
    u"Database connection successfully put back in the pool.",
UTIL_DB_INVALID_CONNECT_PARAMETER:
    u"Invalid parameter for database connection string.",
UTIL_DB_GETCONNECTION_SUCCESS:
    u"Database connection successfully obtained from the pool.",
UTIL_DB_CONNECTION_NOT_AVAILABLE:
    u"Database connection not available from the pool.",
UTIL_DB_CONNECTION_POOL_EXCEPTION:
    u"Cannot put any more database connection in the pool.",
UTIL_DB_SQL_STRING:
    u"SQL: [\n%s\n]",
UTIL_DB_CONNECTED_TO_DB:
    u"Created a connection to database [host=%s, user=%s, db=%s].",
UTIL_DB_INVALID_CONNECTION:
    u"Database connection invalid: [%s].",
UTIL_DB_TRANSACTION_FAILURE:
    u"Transaction failed.",
UTIL_DB_TRANSACTION_ROLLED_BACK:
    u"Transaction rolled back.",
UTIL_DB_TRANSACTION_COMMITTED:
    u"Transaction committed.",
IBROKER_PRINCIPAL_MISMATCH:
    u"User does not belong to this IBroker",
}

